home *** CD-ROM | disk | FTP | other *** search
-
- /*
- ** CONNECT.C - This is the module containing the code for ODBC for
- ** allocation and connection.
- **
- ** (C) Copyright 1991, 1992 By Microsoft Corp.
- */
-
- #include "sample.h"
- #include <Memory.h>
-
-
- // Allocate an ODBC Driver environment (ENV) block.
-
-
- SQL_PRE_API RETCODE SQL_API
- SQLAllocEnv(
- HENV FAR *phenv)
- {
- HENV henv;
-
- henv = (HENV)NewHandleClear( sizeof( ENV ) );
- if( henv )
- HLock( (Handle)henv );
- else
- {
- *phenv = SQL_NULL_HENV;
- return SQL_ERROR;
- }
- *phenv = henv;
- return SQL_SUCCESS;
- }/* end SQLAllocEnv */
-
-
- // Allocate a DBC block.
-
- SQL_PRE_API RETCODE SQL_API
- SQLAllocConnect(
- HENV lpenv,
- HDBC FAR *phdbc)
- {
- HDBC hdbc;
-
-
- hdbc = (HDBC)NewHandleClear( sizeof( DBC ) );
- if( hdbc )
- HLock( (Handle)hdbc );
- else
- {
- *phdbc = SQL_NULL_HDBC;
- return SQL_ERROR;
- }
- *phdbc = hdbc;
- return SQL_SUCCESS;
- }/* end SQLAllocConnect */
-
-
- SQL_PRE_API RETCODE SQL_API
- SQLConnect(
- HDBC hdbc,
- UCHAR FAR *szDSN,
- SWORD cbDSN,
- UCHAR FAR *szUID,
- SWORD cbUID,
- UCHAR FAR *szAuthStr,
- SWORD cbAuthStr)
- {
- //debugstr( "Sample Driver: SQLConnect" );
- return SQL_SUCCESS;
- }/* end SQLConnect */
-
-
- // This function as its "normal" behavior is supposed to bring up a
- // dialog box if it isn't given enough information via "szConnStrIn". If
- // it is given enough information, it's supposed to use "szConnStrIn" to
- // establish a database connection. In either case, it returns a
- // string to the user that is the string that was eventually used to
- // establish the connection.
-
- SQL_PRE_API RETCODE SQL_API
- SQLDriverConnect(
- HDBC hdbc,
- HWND hwnd,
- UCHAR FAR *szConnStrIn,
- SWORD cbConnStrIn,
- UCHAR FAR *szConnStrOut,
- SWORD cbConnStrOutMax,
- SWORD FAR *pcbConnStrOut,
- UWORD fDriverCompletion)
- {
- short iRet;
- BOOL fPrompt = FALSE;
-
- if( (szConnStrIn == NULL) || (!cbConnStrIn)
- || ((cbConnStrIn == SQL_NTS) && (!szConnStrIn[0])) )
- fPrompt = TRUE;
- else
- { // Check connection string for completeness
- if( fDriverCompletion == SQL_DRIVER_COMPLETE
- || fDriverCompletion == SQL_DRIVER_PROMPT )
- fPrompt = TRUE;
- }
- if( fPrompt )
- {
- // It is not necessary to call "MakeProcInstance" if you
- // generate a dialog box from a DLL.
-
- //mj iRet = DialogBox( s_hModule, "EDRIVERCONNECT", pGrafPort, FDriverConnectProc );
- iRet = 333; //mj
- if( (!iRet) || (iRet == -1) )
- return SQL_NO_DATA_FOUND;
- }
- return SQL_SUCCESS;
- }/* end SQLDriverConnect */
-
-
- SQL_PRE_API RETCODE SQL_API
- SQLBrowseConnect(
- HDBC hdbc,
- UCHAR FAR *szConnStrIn,
- SWORD cbConnStrIn,
- UCHAR FAR *szConnStrOut,
- SWORD cbConnStrOutMax,
- SWORD FAR *pcbConnStrOut)
- {
- //debugstr( "Sample Driver: SQLBrowseConnect" );
- return SQL_SUCCESS;
- }/* end SQLBrowseConnect */
-
-
- SQL_PRE_API RETCODE SQL_API
- SQLDisconnect(
- HDBC hdbc)
- {
- //debugstr( "Sample Driver: SQLDisconnect" );
- return SQL_SUCCESS;
- }/* end SQLDisconnect */
-
-
- SQL_PRE_API RETCODE SQL_API
- SQLFreeConnect(
- HDBC hdbc)
- {
-
- //debugstr( "Sample Driver: SQLFreeConnect" );
- HUnlock( (Handle)hdbc );
- DisposHandle( (Handle)hdbc );
- return SQL_SUCCESS;
- }/* end SQLFreeConnect */
-
-
- SQL_PRE_API RETCODE SQL_API
- SQLFreeEnv(
- HENV henv)
- {
-
- //debugstr( "Sample Driver: SQLFreeEnv" );
- HUnlock( (Handle)henv );
- DisposHandle( (Handle)henv );
- return SQL_SUCCESS;
- }/* end SQLFreeEnv */
-